/*******************************************************************************
 * Copyright 2012 Google, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.turbomanage.storm.apt.provider;

import com.turbomanage.storm.apt.ClassModel;
import com.turbomanage.storm.apt.ProcessorLogger;
import com.turbomanage.storm.apt.StormEnvironment;
import com.turbomanage.storm.apt.database.DatabaseModel;
import com.turbomanage.storm.apt.entity.EntityModel;
import com.turbomanage.storm.csv.CsvUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ProviderModel extends ClassModel {

	private DatabaseModel dbModel;

	public ProviderModel(DatabaseModel dbModel) {
		super();
		this.dbModel = dbModel;
		parseQualifiedClassName(dbModel.getDbHelperClass());
	}

	public DatabaseModel getDb() {
		return dbModel;
	}

	public String getAuthority() {
		return getPackage();
	}

	public String getProviderBaseName() {
		return capFirstUnderscoreToCamelCase(dbModel.getDbName()) + "ProviderBase";
	}

	public String getProviderBaseClass() {
		String pkg = this.getPackage();
		if (pkg == null || pkg.length() < 1)
			return getProviderBaseName();
		return this.getPackage() + "." + getProviderBaseName();
	}

	public String getContractBaseName() {
		return capFirstUnderscoreToCamelCase(dbModel.getDbName()) + "ContractBase";
	}

	public String getContractBaseClass() {
		String pkg = this.getPackage();
		if (pkg == null || pkg.length() < 1)
			return getContractBaseName();
		return this.getPackage() + "." + getContractBaseName();
	}
}
